<?php

/**
 * This is the model class for table "ruangkelas".
 *
 * The followings are the available columns in table 'ruangkelas':
 * @property integer $rk_id
 * @property integer $rk_kec
 * @property integer $rk_tk
 * @property integer $rk_sd
 * @property integer $rk_sltp
 * @property integer $rk_smu
 * @property integer $rk_smk
 * @property integer $rk_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $rkKec
 */
class Ruangkelas extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Ruangkelas the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ruangkelas';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('rk_kec, rk_tk, rk_sd, rk_sltp, rk_smu, rk_smk, rk_tahun', 'numerical', 'integerOnly'=>true),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('rk_id, rk_kec, rk_tk, rk_sd, rk_sltp, rk_smu, rk_smk, rk_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'rkKec' => array(self::BELONGS_TO, 'Kecamatan', 'rk_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'rk_id' => 'Rk',
			'rk_kec' => 'Rk Kec',
			'rk_tk' => 'Rk Tk',
			'rk_sd' => 'Rk Sd',
			'rk_sltp' => 'Rk Sltp',
			'rk_smu' => 'Rk Smu',
			'rk_smk' => 'Rk Smk',
			'rk_tahun' => 'Rk Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('rk_id',$this->rk_id);
		$criteria->compare('rk_kec',$this->rk_kec);
		$criteria->compare('rk_tk',$this->rk_tk);
		$criteria->compare('rk_sd',$this->rk_sd);
		$criteria->compare('rk_sltp',$this->rk_sltp);
		$criteria->compare('rk_smu',$this->rk_smu);
		$criteria->compare('rk_smk',$this->rk_smk);
		$criteria->compare('rk_tahun',$this->rk_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}